package com.example.design_pattern.state;

import com.example.design_pattern.exception.WallEntryException;

public class LockedState implements WallState {

    private static final String RIGHT_SPELL = "123456";


    @Override
    public void spell(WallEntry wallEntry, String spellContent) throws WallEntryException {
        if(RIGHT_SPELL.equals(spellContent)){
            System.out.println("LockedState状态下, 咒语正确，状态切换到UnlockedState");
            wallEntry.setmWallState(new UnlockedState());
            return;
        }
        throw new WallEntryException("LockedState状态下,咒语错误");
    }


    @Override
    public void pass(WallEntry wallEntry) throws WallEntryException {
        throw new WallEntryException("LockedState状态下，不允许穿墙");
    }
}
